<template>
  <li>
    <label>
      <input
        type="checkbox"
        :checked="item.seleted"
        @click="checkItem(item.id)"
      />
      <span>{{ item.name }}</span>
    </label>
    <button class="btn" :class="className" @click="buttonHandleMethod(item.id)">
      {{ itemBtn }}
    </button>
  </li>
</template>

<script>
export default {
  name: "ListItem",
  //   props: ["item", "itemBtn"],
  props: {
    item: Object,
    itemBtn: String,
    className: {
      type: String,
      default: "btn-danger",
    },
  },
  methods: {
    buttonHandleMethod(id) {
      this.$bus.$emit("buttonHandleMethod", id);
    },
    checkItem(id) {
      this.$bus.$emit("checkItem", id);
    },
  },
};
</script>

<style scoped>
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}

li:hover {
  background-color: #ddd;
}

li:hover button {
  display: block;
}
.btn {
  /* display: inline-block; */
  padding: 4px 12px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.btn-danger {
  color: #fff;
  background-color: #da4f49;
  border: 1px solid #bd362f;
}
.btn-edit {
  color: #fff;
  background-color: skyblue;
  border: 1px solid rgb(85, 167, 199);
  margin-right: 3px;
}

.btn-danger:hover {
  color: #fff;
  background-color: #bd362f;
}

.btn:focus {
  outline: none;
}
</style>